package com.sjb.training.lambda;

import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 有点儿意思
 * @Description:
 */
public class Test {

    public static void main(String[] args) {
       ThreadPoolExecutor threadPoolExecutor =  new ThreadPoolExecutor(16, 16, 1000, TimeUnit.MILLISECONDS,
                new ArrayBlockingQueue<>(100), r -> {
            Thread thread = new Thread(r);
            thread.setName("test");
            thread.setDaemon(false);
            return  thread;
        });

        for (int i = 0; i < 10; i++) {
            threadPoolExecutor.execute(() -> {
                String threadName = Thread.currentThread().getName();
                System.out.println("正在执行的线程：" + threadName);
            });
        }
        // 关闭线程池
        threadPoolExecutor.shutdown();
    }
}
